<?php

require_once ('Zend\Controller\Action.php');

class Base_Controller extends Zend_Controller_Action {
	protected $logger;
	/**
	 * 
	 * uid from the url, not login user id
	 * @var String
	 */
	protected $uid = null;
    public function init()
    {
        /* Initialize action controller here */
    	$this->logger = Zend_Registry::get("logger");
    	
    	//start the session
    	session_start();
    	
    	//show something about this user
    	//may be different from login user
    	if (isset($_GET['uid'])) {
    		$this->uid=$_GET['uid'];
    		$this->view->uid=$_GET['uid'];
    	}
    }
    
    /**
     * has user logged in? 
     */
    protected function isLogin(){
    	return isset($_SESSION["userinfo"]);
    }
    
    /**
     * get currently login user id
     * return null if not login
     */
    protected function getLoginUid(){
    	if ($this->isLogin()) {
    		return $_SESSION["userinfo"]["uid"];
    	} else {
    		return null;
    	}
    }
	
}

?>